package com.atguigu.gmall.user.rpc;

import com.atguigu.gmall.common.interceptor.component.UserAuthComponent;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.user.entity.UserAddress;
import com.atguigu.gmall.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author:lyd
 * @Date:2023/9/4 19:31
 * @Version:1.0
 * @Description
 **/
@RequestMapping("/api/inner/user")
@RestController
public class UserAddressRpcController {

    @Autowired
    UserAddressService addressService;

    @Autowired
    UserAuthComponent userAuth;

    /**
     * 获取用户地址列表
     * @return
     */
    @GetMapping("/address")
    public Result<List<UserAddress>> getAddressList() {
        Long userId = userAuth.getUserAuth().getUserId();
        List<UserAddress> addressList = addressService.getAddressList(userId);
        return Result.ok(addressList);
    }

}
